import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'
import menu from './modules/menu'

// console.log(app, 'app')
Vue.use(Vuex)
// 导包高级写法，自动导入
// const req = require.context('./modules', false, /\.js$/)
// // console.log(req, '第一个')
// // console.log(req.keys(), '第一个')
// // console.log(req.keys().map(item => item.split('./')[1]).map(item => item.split('.js')[0]))
// // console.log(req.keys().map(item => req(item)))
// // console.log(req.keys().map(req), '12')
// const mdNmae = req.keys().map(item => item.split('./')[1]).map(item => item.split('.js')[0])
// const mdM = req.keys().map(req)

// const obj = {}
// mdNmae.forEach((element, index) => {
//   obj[element] = mdM[index].default
// })
const store = new Vuex.Store({
  modules: {
    app,
    settings,
    user,
    menu
  },
  getters
})

export default store
